package com.lecture.java8.mvel;

import org.mvel2.MVEL;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author luyn
 * @version 1.0
 * @description
 * @date 2020/8/15 14:56
 */
public class MvelTest {

    public static void main(String[] args) {
        String expression = "TCODE_1598319038854 > 50000 && TCODE_1598319040669 < 10000";

        Map<String, Object> vars = new HashMap<>();
        vars.put("TCODE_1598319040669", 780L);
        vars.put("TCODE_1598319038854", 2);

        Boolean result = (Boolean) MVEL.eval(expression, vars);
        System.out.println(result);
        if (result) {
            System.out.println("It works!");
        }


        /*Map<String, Integer> map = new HashMap<>();
        map.put("1070F1_F31_J88", 1);
        map.put("1070F1_F31_J87", 1);
        Map<String, Integer>
        new_map = new HashMap<>();
        map.forEach((k, v) -> {
            System.out.println("修改前的k：" + k);
            System.out.println("修改前的v：" + v);
            new_map.put("T" + k, map.get(k));
        });
        System.out.println("----------------");
             System.out.println("new_map：" + k);
            System.out.println("new_map：" + v);
        });
        StringBuffer str = new StringBuffer();
        str.append("1,2,3,3,");
        str.deleteCharAt(str.length()-1);
        System.out.println(str);*/
    }
}
